//
//  CSGXDisplayView.m
//  CarSalesMS_GCX
//
//  Created by Ssky on 2016/12/22.
//  Copyright © 2016年 Tony. All rights reserved.
//

#import "CSGXDisplayView.h"

@interface CSGXDisplayView ()

@property (nonatomic, weak) UILabel *lblTitle;
@property (nonatomic, weak) UILabel *lblUnit;
@property (nonatomic, weak) UITextField *txtCount;


@end

@implementation CSGXDisplayView









#pragma mark - setupUI
- (void)setupUI {
    //
    UILabel *lblTitle = [UILabel gx_labelWithText:@"" fontSize:12 color:kColorBar];
    [self addSubview:lblTitle];
    self.lblTitle = lblTitle;
    
    [lblTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self).mas_offset(0);
        make.right.equalTo(self.mas_centerX).mas_offset(-20);
    }];
    
    //
    UITextField *txtCount = [[UITextField alloc] init];
    [self addSubview:txtCount];
    self.txtCount = txtCount;
    
    txtCount.font = [UIFont systemFontOfSize:12];
    txtCount.layer.borderColor = [UIColor grayColor].CGColor;
    txtCount.layer.borderWidth = 1;
    txtCount.layer.cornerRadius = 5;
    txtCount.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 3, 5)];
    txtCount.leftViewMode = UITextFieldViewModeAlways;
    
    [txtCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self).mas_offset(0);
        make.leading.equalTo(self.mas_centerX).mas_offset(-10);
        make.width.mas_offset(40);
    }];
    
    //
    UILabel *lblUnit = [UILabel gx_labelWithText:@"" fontSize:12 color:[UIColor grayColor]];
    [self addSubview:lblUnit];
    self.lblUnit = lblUnit;
    
    [lblUnit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self).mas_offset(0);
        make.left.equalTo(txtCount.mas_right).mas_offset(5);
    }];
}






#pragma mark - setter & getter
- (void)setTitle:(NSString *)title {
    _title = title.copy;
    self.lblTitle.text = _title;
}


- (void)setUnit:(NSString *)unit {
    _unit = unit.copy;
    self.lblUnit.text = _unit;
}

- (void)setCount:(NSString *)count {
    _count = count.copy;
    self.txtCount.text = _count;
}


- (void)setDisplayViewDict:(NSDictionary *)displayViewDict {
    _displayViewDict = displayViewDict;
    
    self.title = displayViewDict[@"title"];
    self.count = displayViewDict[@"count"];
    self.unit = displayViewDict[@"unit"];
}



@end
